﻿using System.Data;

namespace SuperStar.Models
{
    public partial class SuperStarEntities
    {
        public T GetById<T>(object id) where T : class
        {
            EntityKey key = CreateKey<T>(id);
            return (T)GetObjectByKey(key);
        }

        private EntityKey CreateKey<T>(object id)
        {
            var type = typeof(T);
            return new EntityKey(DefaultContainerName + "." + type.Name, "ID", id);
        }
    }
}
